
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
    .box {
        width:500px;
        height:300px;
        text-align: center;
        margin: 20 auto;
        border: 1px solid red;
    }
</style>

<body>
    <div id="app">
     <div class="box">
        <p>欢迎光临_vue开发的收银系统_水果店</p>
        <p><strong>苹果10￥/斤，折扣 < 8 折 ></strong></p>
        <p>请输入你要购买的斤数 <input type="number" placeholder="请输入购买的斤数" v-model.number="quantity"></p>
        <p><button @click="pay">结账买单~</button></p>
        <p>结账单：总价{{ totalPrice }}￥元 折后价：{{ totalPrice * 0.8 }}￥元 省了：{{ totalPrice * 0.2 }}￥元</p>
     </div>


    </div>
 
</body>
<script src="./vue.js" ></script>
<script>
   const app = new Vue({
    el:'#app',
    data:{
        quantity:0,
        totalPrice:0
    },
    methods:{
        pay(){
            this.totalPrice = parseInt(this.quantity.toFixed(2)* 100) / 10
        }
    }

   })
</script>
</html>